#ifndef __ST1624_H
#define	__ST1624_H

#include "main.h"

/*#define IIC_SCL PFout(1)  //模拟输出时钟脉冲
#define IIC_SDA PFout(0)  //数据线定义输出
#define IIC_WP  PFout(2)  //数据写保护引脚*/

#define READ_SDA()    HAL_GPIO_ReadPin(I2C1_SDA_GPIO_Port, I2C1_SDA_Pin)  //数据线定义输入

#define Page_Size 16     //一页存储的字节数，具体看相应器件的datasheet

#define IIC_SCLHigh()         GPIOB->BSRR = I2C1_SCL_Pin
#define IIC_SCLLow()          GPIOB->BRR = I2C1_SCL_Pin

#define IIC_SDAHigh()         GPIOB->BSRR = I2C1_SDA_Pin
#define IIC_SDALow()          GPIOB->BRR = I2C1_SDA_Pin


void IIC_SDA_IN(void);   //IO定义输入输出配置
void IIC_SDA_OUT(void);
	
void IIC_Init(void);
void IIC_Start(void);
void IIC_Stop(void);
uint8_t IIC_Wait_Ack(void);
void IIC_Ack(void);
void IIC_NAck(void);
void IIC_Write_Byte(uint8_t txd);
uint8_t IIC_Read_Byte(void);
uint8_t Write_Device_Addr(uint16_t addr);
void Search_Device_Addr(void);
uint8_t Device_Read_One_Byte(uint8_t IC_Addr,uint8_t Addr);
void Device_Write_One_Byte(uint8_t IC_Addr,uint8_t Addr,uint8_t data);
void Device_Read_Bytes(uint8_t IC_Addr,uint8_t Addr,uint8_t *buf,uint8_t len);
void Device_Write_Bytes(uint8_t IC_Addr,uint8_t Addr,uint8_t *buf,uint8_t len);
void Device_Page_Write(uint8_t IC_Addr,uint8_t Addr,uint8_t *buf,uint8_t len);

#endif
